package at.fhooe.mc.master.clc.client.view;


import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.visualization.client.DataTable;

public abstract class AbstractGraphView extends Composite implements IAbstractGraphView
{
	protected FlexTable graphHeader = new FlexTable();
	
	protected VerticalPanel panel = new VerticalPanel();
	protected FlexTable graphTable = new FlexTable();
	protected Button closeButton = new Button("Remove Graph");
	
	protected int key;
	private String objectIdHeader = "graph-panel-";
	
	public AbstractGraphView()
	{
		// set the id of the HTML element, this is needed for more
		// complex graphs that change their appearance through javascript
		graphTable.getElement().setId(getObjId());
		
		closeButton.addStyleName("rightAllignedButton");
		graphHeader.setWidget(0, 5, closeButton);
		
		panel.add(graphHeader);
		panel.add(graphTable);
		initWidget(panel);
	}
	
	@Override
	public abstract void setGraph(String jsonData, String title, String axisTitle);
	
	public void setKey(int key)
	{
		this.key = key;
	}

	public int getKey()
	{
		return this.key;
	}
	
	public Button getRemoveButton()
	{
		return this.closeButton;
	}
	
	protected String getObjId()
	{
		return objectIdHeader + getKey();
	}
}
